-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang][OpenMP] Bug fix Default clause variable category #168846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chandraghale
merged 3 commits into
llvm:main
from
SunilKuravinakop:patch_fix_variable_category2
Nov 21, 2025
Merged
[Clang][OpenMP] Bug fix Default clause variable category #168846
chandraghale
merged 3 commits into
llvm:main
from
SunilKuravinakop:patch_fix_variable_category2
Nov 21, 2025
+89
−3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…de in test to restore Ubuntu build. This is not needed as allocatable modifier is not applicable to the default clause in C/C++.
builders at Google, Reported by Prabhu Rajasekaran.
Member
|
@llvm/pr-subscribers-clang Author: None (SunilKuravinakop) ChangesSame changes as in fix for #165276 except for changes in test case :
Full diff: https://github.com/llvm/llvm-project/pull/168846.diff 2 Files Affected:
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 81c591a00cfc6..31c8f0cd30c56 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1364,15 +1364,15 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
DefaultDataSharingAttributes IterDA = Iter->DefaultAttr;
switch (Iter->DefaultVCAttr) {
case DSA_VC_aggregate:
- if (!VD->getType()->isAggregateType())
+ if (!D->getType()->isAggregateType())
IterDA = DSA_none;
break;
case DSA_VC_pointer:
- if (!VD->getType()->isPointerType())
+ if (!D->getType()->isPointerType())
IterDA = DSA_none;
break;
case DSA_VC_scalar:
- if (!VD->getType()->isScalarType())
+ if (!D->getType()->isScalarType())
IterDA = DSA_none;
break;
case DSA_VC_all:
diff --git a/clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp b/clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp
new file mode 100644
index 0000000000000..e94d590933c85
--- /dev/null
+++ b/clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -Xclang -verify -Wno-vla -fopenmp -fopenmp-version=60 -x c++ -S -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+int global;
+#define VECTOR_SIZE 4
+
+int main (int argc, char **argv) {
+ int i,n;
+ int x;
+
+ n = VECTOR_SIZE;
+
+ #pragma omp parallel masked firstprivate(x) num_threads(2)
+ {
+ int *xPtr = nullptr;
+ // scalar
+ #pragma omp task default(shared:scalar)
+ {
+ xPtr = &x;
+ }
+ #pragma omp taskwait
+
+ // pointer
+ #pragma omp task default(shared:pointer) shared(x)
+ {
+ xPtr = &x;
+ }
+ #pragma omp taskwait
+ }
+
+ int *aggregate[VECTOR_SIZE] = {0,0,0,0};
+
+ #pragma omp parallel masked num_threads(2)
+ {
+ // aggregate
+ #pragma omp task default(shared:aggregate)
+ for(i=0;i<n;i++) {
+ aggregate[i] = &x;
+ }
+ #pragma omp taskwait
+
+ #pragma omp task default(shared:aggregate) shared(x)
+ for(i=0;i<n;i++) {
+ aggregate[i] = &x;
+ }
+ #pragma omp taskwait
+
+ // all
+ #pragma omp task default(shared:all)
+ for(i=0;i<n;i++) {
+ aggregate[i] = &x;
+ }
+ #pragma omp taskwait
+ }
+}
+
+#endif
+
+// CHECK-LABEL: define {{.*}}main.omp_outlined{{.*}}
+// CHECK: store ptr null, ptr{{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: ret void
+//
+// CHECK: define {{.*}}main.omp_outlined{{.*}}
+// CHECK: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: ret void
|
🐧 Linux x64 Test Results
|
chandraghale
approved these changes
Nov 21, 2025
Contributor
chandraghale
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix has been already reviewed from PR165276 . Testcase LGTM.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:openmp
OpenMP related changes to Clang
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Same changes as in fix for #165276 except for changes in test case :
This is not needed as allocatable modifier is not applicable to the default clause in C/C++.
builders at Google, Reported by Prabhu Rajasekaran.